﻿Imports ADOConnection
Public Class frmDoiPassword

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub btThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btThoat.Click
        Me.Close()
    End Sub

    Private Sub btDoiPassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDoiPassword.Click
        'kiem tra xem password co giong nhau khong
        If (txtPassword.Text <> txtPassword2.Text) Then
            MessageBox.Show("Xác nhận mật khẩu không khớp", "Thông báo", MessageBoxButtons.OKCancel)
        Else
            'thay doi password
            'Dim strCauLenh As String = "exec sp_password '" & txtOldPassword.Text & "','" & txtPassword.Text & "'"
            Dim strCauLenh As String = "update tblUser set pass = cast('" + txtPassword.Text + "' as varbinary(30)) where loginname = '" + g_UserName + "'"
            If (XL_DULIEU.ThucHienLenh(strCauLenh) = True) Then
                MessageBox.Show("Đổi mật khẩu  thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information)
                g_Password = txtPassword.Text
                'thay doi lai cau lenh ket noi
                'XL_DULIEU.GanCauLenhKetNoi(g_UserName, txtPassword.Text)
                'myConnStr = GetCnnStrFromFile(Application.StartupPath & "\DBConnect.udl")
                'g_objConnFactory = New CConnFactory(myConnStr, g_UserName, txtPassword.Text)
            Else
                MessageBox.Show("Đổi mật khẩu không thành công! Có thể password cũ không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
            Me.Close()
        End If
    End Sub
End Class